﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using UrlSummary.Models;

namespace UrlSummary.Controllers
{
    public class EnglishWordsController : Controller
    {
        // GET: EnglishWords
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult GetEnglishWords()
        {
            try
            {
                int seach_TypeId = Convert.ToInt32(Request["seach_TypeId"]);
                string seach_UrlLike = Request["seach_UrlLike"];
                //当前页数
                //int pageIndex = Convert.ToInt32(Request.Params["page"]);
                //每页条数的选择项
                //int pageSize = Convert.ToInt32(Request.Params["limit"]);

                //pageIndex = (pageIndex - 1) * pageSize;

                IList<EnglishWordsModel> list = GetEnglishWordsList();
                int count = GetEnglishWordsCount();
                var json = new { count, code = 0, msg = "", data = list, };
                return Json(json);
            }
            catch (Exception x)
            {
                var json = new { code = 2, msg = x.Message, count = 0, data = "", };
                return Json(json);
            }
        }



        public IList<EnglishWordsModel> GetEnglishWordsList()
        {
            string strSql = "SELECT  Id ,        English ,        Chinese ,        Compose FROM    T_EnglishWords";
            IList<EnglishWordsModel> list = DBHelper.ExecuteObjects<EnglishWordsModel>(strSql);
            return list;
        }


        public int GetEnglishWordsCount()
        {
            string strSql = "SELECT COUNT(1) FROM  dbo.T_EnglishWords";
            return Convert.ToInt32(DBHelper.ExecuteScalar(strSql));
        }
    }
}